Skip to content

Fix render callback start/stop race in C++ NativeAnimated#57270

Open
bartlomiejbloniarz wants to merge 1 commit into
mainfrom
export-D109009181
Open

Fix render callback start/stop race in C++ NativeAnimated#57270
bartlomiejbloniarz wants to merge 1 commit into
mainfrom
export-D109009181

Conversation

@bartlomiejbloniarz

@bartlomiejbloniarz bartlomiejbloniarz commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary:
The shared AnimationBackend path now coordinates render callback registration and publication with a small mutex-protected optional callback id. startRenderCallbackIfNeeded holds the lifecycle mutex across AnimationBackend::start and id publication because the backend registers before returning the id; stopRenderCallbackIfNeeded clears the published id under the same mutex before stopping that callback. This closes the window where a concurrent stop could observe no published id and leave the just-registered backend callback orphaned.

The existing non-shared platform callback path remains on the original atomic flag, preserving the avoid-calling-external-code-under-a-mutex behavior.

Changelog: [General][Fixed] - Fix a race in the C++ Animated render-callback lifecycle that could leave stale callbacks running on every frame

Differential Revision: D109009181

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Jun 18, 2026
@meta-codesync

meta-codesync Bot commented Jun 18, 2026

Copy link
Copy Markdown

@bartlomiejbloniarz has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109009181.

Summary:
The shared AnimationBackend path now coordinates render callback registration and publication with a small mutex-protected optional callback id. `startRenderCallbackIfNeeded` holds the lifecycle mutex across `AnimationBackend::start` and id publication because the backend registers before returning the id; `stopRenderCallbackIfNeeded` clears the published id under the same mutex before stopping that callback. This closes the window where a concurrent stop could observe no published id and leave the just-registered backend callback orphaned.

The existing non-shared platform callback path remains on the original atomic flag, preserving the avoid-calling-external-code-under-a-mutex behavior.

Changelog: [General][Fixed] - Fix a race in the C++ Animated render-callback lifecycle that could leave stale callbacks running on every frame

Differential Revision: D109009181
@meta-codesync meta-codesync Bot force-pushed the export-D109009181 branch from 7de94ed to cd09677 Compare June 19, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant